<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Welcome extends CI_Controller
{
	function __construct()
	{
		parent::__construct();

		$this->load->helper('url');
		$this->load->library('tank_auth');
			$this->lang->load('tank_auth');
		$this->load->library('form_validation');
	}

	function index()
	{
		if (!$this->tank_auth->is_logged_in()) {
			redirect('/auth/login/');
		} else {
			$data['user_id']	= $this->tank_auth->get_user_id();
			$data['username']	= $this->tank_auth->get_username();
			$data['role']		= $this->tank_auth->get_role();
			
			if($data['role'] == 2)
			{
		if (!$this->config->item('allow_enrollment', 'tank_auth')) 
		{	// registration is off
			$this->_show_message($this->lang->line('auth_message_registration_disabled'));

		} 
			$this->load->view('welcome', $data);
			}
			elseif($data['role'] == 3)
			{
	$data['deligate_info'] = $this->users->get_all_delegates();
    $this->load->view('auth/styles', $data);
    $this->load->view('Secritariat/Secritariat', $data);	
			}
			elseif($data['role'] == 4)
			{
							// logged in
		
			$this->form_validation->set_rules('transaction_num', 'Transaction number', 'trim|required|xss_clean');
		
			if ($this->form_validation->run()) 
				{		
				if (!is_null($data = $this->tank_auth->get_delegate_payment($this->form_validation->set_value('transaction_num')))) 
					{						// success
					$data['requested_transaction_num'] = $this->payment->get_delegate_payment();

						$this->load->view('Secritariat/Payment_approval', $data);	
					} 

				}
			else
				{

			
$this->load->view('Secritariat/Payment_approval_form', $data);	
				
				
				}
		
    $this->load->view('auth/styles', $data);
    
		
			}
		}
	}

function _show_message($message)
	{
		$this->session->set_flashdata('message', $message);
		redirect('/auth/');
	}	
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */